const styleIndex = getApp().globalData.month;

Component({
    data: {
        styleIndex,
        selected: 0,
        color: "#aaaaaa",
        selectedColor: "#222222",
        selectedColor9: "#ec7044",
        visible: false,
        list: [{
                pagePath: "/pages/active/active",
                text: "活动",
                iconPath: "/assets/tab_home_1.png",
                selectedIconPath: "/assets/tab_home_2.png"
            }, {
                pagePath: "",
                text: "",
                iconPath: "/assets/tab_apped.png",
                selectedIconPath: "/assets/tab_apped.png"
            }
            /*, {
                        pagePath: "/pages/homestay/homestay",
                        text: "民宿"
                    }*/
            , {
                pagePath: "/pages/myself/myself",
                text: "我的",
                iconPath: "/assets/tab_myself_1.png",
                selectedIconPath: "/assets/tab_myself_2.png"
            }
        ],
        visible: false
    },
    attached() {
        // this.setData({
        //     selectedColor: getApp().globalData.style.theme
        // })
    },
    methods: {
        switchTab(e) {
            const data = e.currentTarget.dataset
            const url = data.path
            if (data.index == 1) {
                this.setData({ visible: true })
                // let userInfo = getApp().globalData.userInfo || "";
                // console.log(userInfo)
                // let expiration = new Date(userInfo.expirationDate).getTime() || 0;
                // if (expiration < new Date().getTime()) {
                //     this.setData({
                //         visible: true
                //     })
                // } else {
                //     wx.navigateTo({
                //         url: '/active/publish/publish'
                //     })
                // }
            } else {
                wx.switchTab({
                    url
                })
                this.setData({
                    selected: data.index
                })
            }
        },
        goPublish () {
            wx.navigateTo({
                url: '/active/publish/publish'
            })
        },
        close () {
            this.setData({ visible: false })
        },
    }
})